#include "dialog.h"
#include "ui_dialog.h"


Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);

    Worker *worker = new Worker;
    worker->moveToThread(&workerThread);
    connect(&workerThread,&QThread::finished,worker,&QObject::deleteLater);
    connect(this,&Dialog::operate,worker,&Worker::doWork);
    connect(worker,&Worker::resultReady,this,&Dialog::on_pushButton_clicked);

    workerThread.start();

}

Dialog::~Dialog()
{
    delete ui;
    workerThread.quit();
    workerThread.wait();
}

void Dialog::on_pushButton_clicked(const QString &res)
{
    ui->textBrowser->setPlainText(res);
}
